package dexter.core.host;

import java.util.Properties;

import dexter.core.common.HostParams;
import dexter.core.common.HostResult;
import dexter.net.msg.common.RequestListener;
import dexter.net.msg.common.RequestParams;
import dexter.net.msg.common.ResponseParams;

public class HostListener implements RequestListener {
	
	public ResponseParams service(RequestParams params) {
		
		System.out.println("NodeListener START execute : "+params+" in Thread : "+Thread.currentThread().getId());
		ResponseParams tr = null;
		
		if (params instanceof HostParams) {
		  HostParams nparams = (HostParams) params;
		  Properties props = nparams.getProps();
		  props.put("clientname",nparams.getClassName());
		  props.put("clientbytes",nparams.getClassBytes());
		  
		  String url =  null;
		  boolean ok;
		  
		  try {
		    //url = Node.create(props);
		    ok = true;
		  } catch(Exception e) {
			ok = false;  
		  }
		  
		  tr = new HostResult(url,ok);
		}
		
		System.out.println("NodeListener END execute : "+params+" in Thread : "+Thread.currentThread().getId());
		
		return tr;
		
	}

}